package com.zcx.common;

import android.app.Activity;
import android.app.Dialog;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;

/**
 * @author：zcx
 * @date:on 2018/3/7 0007 10:03
 */

public class DialogHelper {
    public static ProgressDialog showDialog(@NonNull Activity activity, ProgressDialog mProgressDialog, @StringRes int strId) {
        return showDialog(activity, mProgressDialog, activity.getString(strId));
    }

    public static ProgressDialog showDialog(@NonNull Activity activity, ProgressDialog mProgressDialog, String str) {
        if (Helper.isNull(mProgressDialog)) {
            mProgressDialog = new ProgressDialog(activity);
        }
        dismissDialog(mProgressDialog);
        mProgressDialog
                .setLoadContent(str)
                .show();
        return mProgressDialog;
    }

    public static void dismissDialog(ProgressDialog mProgressDialog) {
        if (Helper.isNotNull(mProgressDialog) && mProgressDialog.isShowing()) {
            mProgressDialog.dismiss();
        }
    }

    public static void clearDialog(Dialog dialog) {
        if (null != dialog) {
            if (dialog.isShowing()) {
                dialog.dismiss();
            }
            dialog = null;
        }
    }
}
